<template>
	<view class="">
		<view class="nav-back">
			<top-heigth></top-heigth>
			<uv-navbar :fixed="false" bg-color="rgba(0,0,0,0)" :title="backTitle" :safeAreaInsetTop="false">
				<template v-slot:left>
					<view class="uv-nav-slot" @click="goback()">
						<image src="/static/image/go.png" style="width: 40rpx; height: 40rpx;" mode="" class="image-top"></image>
					</view>
				</template>
			</uv-navbar>
		</view>
		<view class="content-box">
			<view class="time-box">
				<view class="time-item" 
					v-for='(item,index) in timeList' 
					:key='index' 
					@tap.stop='changeDate(item.value)'
					:class="dateCondition == item.value ? 'active' : ''"
				>
					{{ item.title }}
				</view>
			</view>
			<view class="statis-box">
				<view class="statis-item">
					<view class="statis-text">接单量</view>
					<view>{{ pageData.finish }}</view>
				</view>
				<view class="statis-item one">
					<view class="statis-text">拒单量</view>
					<view>{{ pageData.refuse }}</view>
				</view>
				<view class="statis-item two">
					<view class="statis-text">总收益</view>
					<view>{{ pageData.income }}</view>
				</view>
			</view>
			<view class="statis-box">
				<view class="statis-item three">
					<view class="statis-text">已提现金额</view>
					<view>{{ pageData.cash }}</view>
				</view>
				<view class="statis-item four">
					<view class="statis-text">接单金额</view>
					<view>{{ pageData.amount }}</view>
				</view>
				<view class="statis-item five">
					<view class="statis-text">未提现金额</view>
					<view>{{ pageData.noCash }}</view>
				</view>
			</view>
		</view>
			
	</view>
</template>

<script>
	import TopHeigth from '@/components/TopHeigth.vue'

	export default {
		data() {
			return {
				backTitle:"数据统计",
				userInfo: uni.getStorageSync('userInfo'),
				timeList: [
					{title:'本日',value: 1},
					{title:'本周',value: 2},
					{title:'本月',value: 3},
					{title:'本年',value: 4},
				],
				dateCondition: 1,
				pageData: {}
			}
		},
		components: { TopHeigth },
		onLoad(e) {
			this.getStatistics();
		},
		methods: {			
			getStatistics(){
				uni.$u.http.post('/api/shop/v2_0/tAppStaffRCA/StaffStatistics',{
					 dateCondition: this.dateCondition
				}).then((res) => {
					this.pageData = res.data || {}
				})
				
			},
			changeDate(val){
				this.dateCondition = val;
				this.getStatistics();
			},
			goback(){
				uni.navigateBack()
			},
		}
	}
</script>

<style lang="scss" scoped>
	@mixin flex($direction: row) {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: $direction;
	}
	.uv-nav-slot {
		@include flex;
		align-items: center;
		justify-content: space-between;
		border-width: 0.5px;
		border-radius: 100px;
		border-color: #dadbde;
		padding: 3px 7px;
		opacity: 0.8;
	}
	.content-box{
		background: #FFFFFF;
		border-radius: 20rpx;
		margin: 20rpx;
		padding-bottom: 20rpx;
		.time-box{
			display: flex;
			.time-item{
				flex: 1;
				height: 80rpx;
				background: #F8F8F8;
				border-radius: 8rpx;
				font-weight: 400;
				font-size: 28rpx;
				color: #333333;
				line-height: 80rpx;
				text-align: center;
				margin: 40rpx 10rpx;
			}
			.time-item.active{
				background: rgba(39,160,255,0.15);
				border-radius: 8rpx;
				border: 2rpx solid #27A0FF;
				color: #27A0FF;
			}
		}
		.statis-box{
			display: flex;
			.statis-item{
				flex: 1;
				height: 112rpx;
				background: rgba(254,156,82,0.15);
				border-radius: 8rpx;
				border: 2rpx solid #FE9C52;
				color: #FE9C52;
				font-weight: 400;
				font-size: 28rpx;
				text-align: center;
				margin: 10rpx 10rpx;
			}
			.statis-item.one{
				background: rgba(248,93,97,0.15);
				border-radius: 8rpx;
				border: 2rpx solid #F85D61;
				color: #F85D61;
			}
			.statis-item.two{
				background: rgba(39,199,255,0.15);
				border-radius: 8rpx;
				border: 2rpx solid #27C7FF;
				color: #0CBAF7;
			}
			.statis-item.three{
				background: rgba(4,179,140,0.15);
				border-radius: 8rpx;
				border: 2rpx solid #04B38C;
				color: #04B38C;
			}
			.statis-item.four{
				background: rgba(0,123,255,0.15);
				border-radius: 8rpx;
				border: 2rpx solid #007BFF;
				color: #007BFF;
			}
			.statis-item.five{
				background: rgba(124,110,242,0.15);
				border-radius: 8rpx;
				border: 2rpx solid #7C6EF2;
				color: #7C6EF2;
			}
			.statis-text{
				padding: 12rpx 0;
			}
		}
		
	}
	
</style>
